import sys, string, os
apps=[]
app=sys.argv[1].split('\\')

for i in os.walk(sys.argv[1]+'\\e$\\prepare\\'):
	if i[0].split("\\")[5] not in apps and i[0].split("\\")[5] is not "":
		apps.append(i[0].split("\\")[5])


for application in apps:
	app=[]
	cfgarray=[]
	proparray=[]
	application_file=''
	#print sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\'+application+'.txt'
	if application=='esigate-EP':
		application_file='esigate-EC'
	else:
		application_file=application
	
	print "\n\n\n--------------------------------------------------------------"
	
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\param\\groovy-substitute.log','r') as fcfg:
			print fcfg.readline()
	except IOError:
		print "fuck"
	
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\'+application_file+'.txt','r') as fcfg:
			for line in fcfg:
				if " " in line:
					cfgarray.append(line.split(" ")[0])
	except IOError:
		print "fuck"
	
	try :
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\config.properties','r') as fprop:
			for line in fprop:
				if "$" in line:
					proparray.append(line.split("$")[1].strip())
	except IOError:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\esigate.properties','r') as fprop:
			for line in fprop:
				if "=$" in line:
					proparray.append(line.split("=$")[1].strip())
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\status-check.properties','r') as fprop:
				for line in fprop:
					if "=$" in line:
						proparray.append(line.split("=$")[1].strip())
	except IOError:
		print "\n"
		
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\statusFeatures.properties','r') as fprop:
				for line in fprop:
					if "=$" in line:
						proparray.append(line.split("=$")[1].strip())
	except IOError:
		print "\n"
		
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\stateFeatures.properties','r') as fprop:
				for line in fprop:
					if "=$" in line:
						proparray.append(line.split("=$")[1].strip())
	except IOError:
		print "\n"
		
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\authorities.xml','r') as fprop:
				for line in fprop:
					if "=\"$" in line:
						#print line.split("=\"$")
						proparray.append(line.split("=\"$")[1].split("\"")[0].strip())
	except IOError:
		print "\n"
		
	try:
		with open(sys.argv[1]+'\\e$\\prepare\\'+application+'\\param\\srcParam\\listFilesCodiers.properties','r') as fprop:
				for line in fprop:
					if "$" in line:
						proparray.append(line.split("$")[1].split("/")[0].strip())
	except IOError:
		print "\n"
	
	print '\n\n---->properties absentes de '+application_file+'.txt<-------' 
	for a in [aa for aa in proparray if aa not in cfgarray]:
		print a
	'''print '\n\n----->properties inutile dans '+application_file+'.txt et refadmin<-------' 
	[proparray,cfgarray]=[cfgarray,proparray]
	for a in [aa for aa in proparray if aa not in cfgarray]:
		print a
	'''
	